<template>
  <div>
    <el-container>
      <el-header>
        <span>我的预约</span>
      </el-header>
    </el-container>
    <div class="graduate-info">
      <div v-for="item in list" :key="item.aid">
        <el-descriptions
          class="margin-top"
          :title="item.name"
          :column="3"
          border
        >
          <template slot="extra">
            <el-button type="danger" size="small" @click="cancel(item)"
              >取消预约</el-button
            >
          </template>
          <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-user-solid"></i>
              公司
            </template>
            {{ item.company }}
          </el-descriptions-item>
          <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-location"></i>
              地点
            </template>
            {{ item.localtion }}
          </el-descriptions-item>
          <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-time"></i>
              开始时间
            </template>
            <el-date-picker
              type="datetime"
              readonly
              v-model="item.time"
            ></el-date-picker>
          </el-descriptions-item>
          <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-open"></i>
              完成状态
            </template>
            {{ item.finish }}
          </el-descriptions-item>
        </el-descriptions>
      </div>
    </div>
    <el-container>
      <el-footer>
        <div>
          <span>专注于互联网校招</span>
        </div>
      </el-footer>
    </el-container>
  </div>
</template>

<script>
export default {
  name: "RecommendGraduateappointment",

  data() {
    return {
      list: [],
      cancelObj: {
        aid: 0,
      },
    };
  },

  mounted() {
    this.loadList();
  },

  methods: {
    loadList() {
      this.$axios
        .post("/appointment/queryByGid")
        .then((res) => {
          if (res.data.result != null) {
            this.list = res.data.result;
          } else {
            return;
          }
        })
        .catch((error) => {
          console.log(error);
          this.$message({
            message: "系统错误!!!",
            type: "error",
          });
        });
    },
    cancel(item) {
      console.log(item);
      this.cancelObj.aid = item.aid;
      this.$axios
        .post("/appointment/cancel", this.cancelObj)
        .then((res) => {
          var response = res.data.desc;
          if (response === "取消失败") {
            this.$message({
              message: "取消失败",
              type: "error",
            });
            return;
          } else if (response === "取消成功") {
            this.$message({
              message: "取消成功",
              type: "success",
            });
            this.loadList();
          }
        })
        .catch((error) => {
          console.log(error);
          this.$message({
            message: "系统错误!!!",
            type: "error",
          });
        });
    },
  },
};
</script>

<style scoped>
.el-header {
  background-color: #409eff;
  color: white;
  line-height: 60px;
}

.el-footer {
  background-color: #409eff;
  color: white;
  line-height: 60px;
}

.el-footer div {
  margin-left: 43%;
}

.graduate-info {
  margin-top: 10px;
  margin-bottom: 10px;
  height: 480px;
  background: whitesmoke;
  /* background-image: url(https://img2.baidu.com/it/u=2699034911,1369297825&fm=253&fmt=auto&app=138&f=JPEG?w=890&h=500); */
  /* background-size: 1355px 480px; */
  overflow: auto;
}
</style>
